home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / earcd / util / dir / managers.lha / Managers / Dir / dir.wrap < prev    next >
Text File  |  1997-01-15  |  6KB  |  226 lines

  1. G4C
  2.  
  3. ; This is a GUI script for the "Wrap" CLI command
  4. ; GUI script written by Graham Maddox & D.Keletsekis
  5. ; Wrap command by D.Keletsekis
  6.  
  7. ; ----------------- The window
  8.  
  9. WinBig -1 -1 240 150 'TextWrap v2.0'
  10. WinType 11110001  ; it's resizable & font sensitive with all gadgets
  11.  
  12. ; ----------------- General events
  13.  
  14. xOnLoad        ; Set the default values
  15. tw_ext = 1    ; Add extensions
  16. tw_newdir = 0        ; do not save to new dir
  17. setgad dir.wrap 2 off    ; and turn off the dir-select gadgets
  18. setgad dir.wrap 3 off
  19. tw_dest = RAM:    ; default dir to save in
  20. tw_para = 1       ; leave paragraphs alone
  21. tw_skeol = 2    ; how many end of line characters to skip
  22. tw_strhr = 0    ; don't strip carriage returns (CRs)
  23. tw_addcr = 0    ; don't add CRs
  24. tw_tabflag = 0  ; delete all tabs
  25. tw_tab = 4    ; default tab -> spaces length
  26. setgad dir.wrap 6 off
  27. tw_colflag = 1  ; Yes, change line length.
  28. tw_col = 75     ; to 75 characters per line
  29. guiopen dir.wrap
  30. run 'resident c:wrap pure add'
  31.  
  32.  
  33. xOnClose
  34. delvar tw_#?
  35. guiquit dir.wrap
  36. run 'resident wrap remove'
  37.  
  38.  
  39. ; Some fancy boxes to separate the functions into sections.
  40.  
  41. box 0 0 240 51 out button
  42. box 0 52 240 36 out button
  43. box 0 89 240 35 out button
  44. box 0 125 240 25 out button
  45.  
  46.  
  47. ; ---------------- Do we want to add extensions to the files ?
  48.  
  49. xcheckbox 200 5 26 11 'Add ".wrap" extension' tw_ext 1 0 ON
  50.  
  51.  
  52. ; ---------------- Do we want to save them in an other dir ?
  53.  
  54. xcheckbox 200 17 26 11 'Save to new directory' tw_newdir 1 0 OFF
  55. if $tw_newdir = 1
  56.    setgad dir.wrap 2 on
  57.    setgad dir.wrap 3 on
  58. else
  59.    setgad dir.wrap 2 off
  60.    setgad dir.wrap 3 off
  61. endif
  62.  
  63. ; Text in for new directory
  64.  
  65. xTextIn  10 31 180 15 "" tw_dest "RAM:" 512        ; destination dir
  66. gadid 3
  67.  
  68. ; add a browse button to save typing
  69.  
  70. xbutton 190 31 40 15 "Dir"
  71. gadid 2
  72. reqfile -1 -1 300 -40 "Destination Dir..." dir tw_dest SYS:
  73. update dir.wrap 3 $tw_dest
  74.  
  75. ; ---------------- paragraph options. default is off
  76.  
  77. xcheckbox 10 57 26 11 "Paragraph" tw_para 1 0 on
  78. gadtitle right
  79. if $tw_para = 1
  80.     setgad dir.wrap 4 on
  81. else
  82.     setgad dir.wrap 4 off
  83. endif
  84.  
  85. xhslider 157 57 50 11 "EOLs" tw_skeol 0 30 2 %1ld
  86. gadtitle left
  87. gadid 4
  88.  
  89. ; ------------------- checkboxes for adding/stripping hard returns. 
  90. ; Default (unchecked) is to leave them alone.
  91. ; Check both of them if you want to re-warp PC files
  92.  
  93. xcheckbox 10 72 26 11 "StripCR" tw_strhr 1 0 off
  94. gadtitle right
  95.  
  96. xcheckbox 120 72 26 11 "AddCR" tw_addcr 1 0 off
  97. gadtitle right
  98.  
  99.  
  100. ; =====================================================================
  101. ; Now the sliders for tab settings and width. Default is tab=4 width=75
  102. ; If these are set to off, Tabs & line length will be left alone.
  103. ; NOTE : Max line length that wrap can deal with is 1000 characters.
  104.  
  105. xcheckbox 10 93  26 11 "Tabs" tw_tabflag 1 0 off
  106. gadtitle right
  107. if $tw_tabflag = 0
  108.    setgad dir.wrap 6 off
  109. else
  110.    setgad dir.wrap 6 on
  111. endif
  112.  
  113. xhslider 90 93  115 11 "" tw_tab 0 16 4 %1ld
  114. gadid 6
  115.  
  116. ; --- length slider
  117.  
  118. xcheckbox 10 108 26 11 "Length" tw_colflag 1 0 on
  119. gadtitle right
  120. if $tw_colflag = 0
  121.    setgad dir.wrap 7 off
  122. else
  123.    setgad dir.wrap 7 on
  124. endif
  125.  
  126. xhslider 90 108 115 11 "" tw_col 10 200 75 %1ld
  127. gadid 7
  128.  
  129.  
  130. ; ====================================================================
  131. ; Do yes do, that thing you do, so weeeelllll... (refrain)
  132.  
  133. xbutton 70 130 80 15 START
  134. tw_stopflag = 0            ; reset abort flag
  135. tw_lvid = $$LV_ID
  136. lvmulti dir.gc $tw_lvid first
  137. if $lv_file = ""
  138.    ezreq "I would.. if I had\nsome files.." OK ""
  139.    stop
  140. endif
  141. if $tw_ext = 0            ; check & warn if files will be overwriten
  142.    if $tw_newdir = 0
  143.       ezreq 'With the current settings\nselected files will be\nOverWriten !\n\nIf any file is not a pure\ntext file, it may be trashed!\n\nAre you sure ?\n' "Continue|CANCEL" tw_choice
  144.       if $tw_choice = 0
  145.          stop
  146.       endif
  147.    endif
  148. endif
  149. guiwindow dir.wrap wait
  150. gosub dir.wrap setup                    ; construct the command line
  151. launch 1 'wrap $lv_file $tw_options'        ; and launch the first file
  152.  
  153.  
  154. xOnReturn 1            ; upon returning, launch the next file
  155. lvmulti dir.gc $tw_lvid off
  156. if $tw_stopflag = 1        ; check if user has aborted meanwhile
  157.    guiwindow dir.wrap resume
  158.    lvdir dir.gc $tw_lvid refresh
  159.    stop
  160. endif
  161. lvmulti dir.gc $tw_lvid next
  162. if $lv_file > ""
  163.    gosub dir.wrap setup
  164.    launch 1 'wrap $lv_file $tw_options'
  165. else
  166.    guiwindow dir.wrap resume
  167.    if $tw_newdir = 1
  168.       lvdir dir.gc $tw_lvid #$tw_dest
  169.       setwintitle dir.wrap '$tw_dest                                    '
  170.    else
  171.       lvdir dir.gc $tw_lvid refresh
  172.    endif
  173. endif
  174.  
  175.  
  176. xroutine setup            ; construct the options command line
  177. tw_options = ""
  178. extract lv_file file tw_file
  179. if $tw_ext = 1
  180.    extract tw_file unquote tw_file2
  181.    appvar  tw_file2 .wrap               ; add the file extension
  182.    tw_file =  '\"$tw_file2\"'
  183. endif
  184. if $tw_newdir = 1
  185.    JoinFile $tw_dest $tw_file tw_file   ; save to new dir
  186. else
  187.    extract lv_file path tw_path
  188.    JoinFile $tw_path $tw_file tw_file   ; or to the same dir
  189. endif
  190. tw_options = '$tw_file '        ; this is our correct file name
  191. if $tw_para = 1
  192.    appvar tw_options 'PARA=$tw_skeol '  ; paragraph wraping ?
  193. endif
  194. if $tw_strhr = 1
  195.     appvar tw_options 'StripCR '    ; strip CRs ?
  196. endif
  197. if $tw_addcr = 1
  198.     appvar tw_options 'AddCR '        ; add CRs ?
  199. endif
  200. if $tw_tabflag = 1
  201.     appvar tw_options 'TAB=$tw_tab '    ; convert tabs ?
  202. endif
  203. if $tw_colflag = 1
  204.     appvar tw_options 'L=$tw_col'    ; wrap file ?
  205. endif
  206.  
  207.  
  208. ; ------------------------ Stop processing the rest of the files
  209.  
  210. xButton 150 130 80 15 _STOP
  211. tw_stopflag = 1
  212.  
  213.  
  214. ; ------------------------ If the worst happens..
  215.  
  216. xOnFail
  217. guiwindow dir.wrap resume
  218. ezreq "Error wraping file :\n$tw-file" OK ""
  219.  
  220.  
  221. ; ------------------------- Must tell everyone how great I am..... 8)
  222.  
  223. xbutton 20 130 26 15  _?
  224. EzReq "TextWrap 2.0\n\nBy :\nG.Maddox & D.Keletsekis\n\nFor use with the c:Wrap\ncommand, by D.Keletsekis\n" "Who cares.." opt
  225.  
  226.